<template>
	<div class="app-container">
	  <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
		<el-form-item label="模型名称" prop="modelName">
		  <el-input
			v-model="queryParams.modelName"
			placeholder="请输入模型名称"
			clearable
			@keyup.enter="handleQuery"
		  />
		</el-form-item>
		<el-form-item label="省" prop="province">
		  <el-select v-model="queryParams.province" placeholder="请选择省" @change="chooseProvince" clearable>
			 <el-option
				  v-for="item in provinceData"
				  :key="item.id"
				  :label="item.name"
				  :value="item.id">
			  </el-option>
		  </el-select>
		</el-form-item>
		<el-form-item label="市" prop="city">
		  <el-select v-model="queryParams.city" placeholder="请选择市" @change="chooseCity" clearable>
			 <el-option
				  v-for="item in cityData"
				  :key="item.id"
				  :label="item.name"
				  :value="item.id">
			  </el-option>
		  </el-select>
		</el-form-item>
		<!--<el-form-item label="区/县" prop="areaId">
		  <el-select v-model="queryParams.areaId" placeholder="请选择区/县" clearable>
			 <el-option
				  v-for="item in areaData"
				  :key="item.id"
				  :label="item.name"
				  :value="item.id">
			  </el-option>
		  </el-select>
		</el-form-item>-->
		<el-form-item>
		  <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
		  <el-button plain icon="Refresh" @click="resetQuery">重置</el-button>
		</el-form-item>
	  </el-form>
  
	  <el-row :gutter="10" class="mb8">
		<!--<el-col :span="1.5">
		  <el-button
			type="primary"
			plain
			icon="Plus"
			@click="handleAdd"
		  >新增</el-button>
		</el-col>-->
		<!--<el-col :span="1.5">
		  <el-button
			type="success"
			plain
			icon="Edit"
			:disabled="single"
			@click="handleUpdate"
			v-hasPermi="['system:difference:edit']"
		  >修改</el-button>
		</el-col>-->
		<!--<el-col :span="1.5">
		  <el-button
			type="danger"
			plain
			icon="Delete"
			:disabled="multiple"
			@click="handleDelete"
			v-hasPermi="['system:difference:remove']"
		  >删除</el-button>
		</el-col>-->
		<!--<el-col :span="1.5">
		  <el-button
			type="warning"
			plain
			icon="Download"
			@click="handleExport"
			v-hasPermi="['system:difference:export']"
		  >导出</el-button>
		</el-col>-->
		<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
	  </el-row>
  
	  <el-table v-loading="loading" :data="casualtiesList" stripe>
		<!--<el-table-column type="selection" width="55" align="center" />-->
		<el-table-column label="模型名称" align="center" prop="modelName" >
			<template #default="scope">
			  <el-button type="text" @click="edit(scope.row)">{{
				scope.row.modelName
			  }}</el-button>
			</template>
		  </el-table-column>
		<el-table-column label="省" align="center" prop="province" />
		<el-table-column label="市" align="center" prop="city" />
		
		
		<el-table-column label="是否默认" align="center" prop="isDefault">
			<template #default="scope">
			<span v-if="scope.row.isDefault=='0'">否</span>
			<span v-if="scope.row.isDefault=='1'">是</span>
		  </template>
		</el-table-column>
		<el-table-column label="维护人" align="center" prop="createUserName" />
		<el-table-column label="维护人所属单位" align="center" prop="orgName" />
		
		<!--<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
		  <template #default="scope">
			<el-button
			  type="text"
			  @click="handleDelete(scope.row)"
						  v-if="scope.row.taskStatus!=2 && scope.row.flag==2"
			>删除</el-button>
			
		  </template>
		</el-table-column>-->
	  </el-table>
	  
	  <pagination
		v-show="total>0"
		:total="total"
		v-model:page="queryParams.page"
		v-model:limit="queryParams.rows"
		@pagination="getList"
	  />
  
	  <!-- 添加或修改区县致死性差异性对话框 -->
	  <el-dialog :title="title" v-model="open" width="850px" append-to-body>
		<el-form ref="casualtiesRef" :model="form" :rules="rules" label-width="120px">
			<p class="dialogTitle">{{title}}</p>
				   <el-row>
					 <el-col :span="12">
					 <el-form-item label="模型名称" prop="modelName" v-if="isCopy">
						 {{form.modelName}}		          
				  </el-form-item>
				  <el-form-item label="模型名称" prop="modelName" v-else>
						 <el-input v-model="form.modelName" placeholder="请输入模型名称" />		          
				  </el-form-item>
				 </el-col>
				 <el-col :span="12">
					 <el-form-item label="是否默认" prop="" v-if="isCopy">
						 {{form.isDefault=='0'?'否':'是'}}		          
				  </el-form-item>
				  <el-form-item label="是否默认" prop="" v-else>
						 <el-select v-model="form.isDefault" disabled style="width: 100%;">
					 <el-option
					  v-for="item in [
						{ value: '0', label: '否' },
						{ value: '1', label: '是' },
					  ]"
					  :key="item.value"
					  :label="item.label"
					  :value="item.value"
					>
				</el-option>
					 </el-select>	          
				  </el-form-item>
				 </el-col>
				 
				 </el-row>
				   <el-row>
					<el-col :span="24">
				  <el-form-item label="地区" prop="" v-if="isCopy||isEditDefault">
					{{form.province}} - {{form.city}}
				  </el-form-item>
				  <el-form-item label="地区" prop="" v-else>
					
					<el-form-item label="省" prop="provinceId" label-width="50px">
						<el-select v-model="form.provinceId" :disabled="isDisableds" placeholder="请输入省" @change="chooseFormProvince"  style="width: 160px;">
							 <el-option
						  v-for="item in provinceFormData"
						  :key="item.id"
						  :label="item.name"
						  :value="item.id">
						  </el-option>
						  </el-select>
					  </el-form-item>
					  <el-col :span="16">
						  <el-form-item label="市" prop="cityId" label-width="50px">
							  <el-radio-group v-model="radio" @change="chooseRadio">
									<el-radio label="1">全部</el-radio>
									<el-radio label="2">
										<el-select v-model="form.cityId" placeholder="请输入市" multiple collapse-tags :disabled="isCityEdit" style="width: 200px;">
										 <el-option
									  v-for="item in cityFormData"
									  :key="item.id"
									  :label="item.name"
									  :value="item.id">
									  </el-option>
									  </el-select>
									</el-radio>
								  </el-radio-group>
								</el-form-item>
							</el-col>
					  
						
  
				  </el-form-item>
				  </el-col>
			 
			 </el-row>
				 <el-row>
					 <el-col :span="12">
					 <el-form-item label="维护人" prop="">
						 {{form.createUserName}}		          
				  </el-form-item>
				 </el-col>
				 <el-col :span="12">
					 <el-form-item label="维护人单位" prop="">
						 {{form.orgName}}		          
				  </el-form-item>
				 </el-col>
				 
				 </el-row>
				 
				   <el-row>
					  <el-col :span="6" class="tab-title">
						  建筑物破坏评估模型
					  </el-col>
				  </el-row>
				  <el-row>
					  <el-col :span="12" :offset="6">
						  <span style="font-size: 16px;font-weight: bold;font-style: italic;">F(I) = ∑<sub>n</sub> ∑<sub>s</sub> ∑<sub>j</sub> P [<span style="position: absolute;top: -15px;">D<sub>j</sub></span>—<span style="position: absolute;top: 12px;margin-left: -10px;">I</span>] * B<sub>s</sub> </span><br/><br/>
						  式中：<br/>
						  I	--表示地震烈度；<br/>
						  N	--表示烈度圈I内的单元数据（公里格网）；<br/>
						  F(I)--表示在烈度I内，各类建筑的每类破坏面积之和；<br/>
						  P[D<sub>j</sub>/I]--表示s类建筑在烈度I，j类破坏比率；<br/>
						  B<sub>s</sub>	--表示I烈度，每个单元中s类建筑的面积。<br/>
					  </el-col>
				  </el-row>
		  <el-row>
					  <el-col :span="6" class="tab-title">
						  根据损坏比计算死亡比
					  </el-col>
				  </el-row>
				  <el-row>
					  <el-col :span="12" :offset="6" v-if="isCopy">
						  <span style="font-size: 16px;font-weight: bold;font-style: italic;">log RD = 12.479 A<sup>0.1</sup>-13.3 </span><br/><br/><br/>
						  RD为死亡比，A为房屋毁坏比（房屋毁坏面积/房屋总面积）<br/>
						  
					  </el-col>
					  <el-col :span="12" :offset="6" v-else>
						  <span style="font-size: 16px;font-weight: bold;font-style: italic;">log RD = 
						  <el-form-item prop="smrsNumber1" label-width="0" style="display: inline-block;">
							  <el-input v-model="form.smrsNumber1" placeholder="保留三位小数" style="width: 110px;" />
						  </el-form-item>
							   A<sup>0.1</sup>- 
						   <el-form-item prop="smrsNumber2" label-width="0" style="display: inline-block;">
							   <el-input v-model="form.smrsNumber2" placeholder="保留两位小数" style="width: 110px;" />
						  </el-form-item>
						  </span> <br/><br/><br/>
						  RD为死亡比，A为房屋毁坏比（房屋毁坏面积/房屋总面积）<br/>
						  
					  </el-col>
				  </el-row>
		  <el-row>
					  <el-col :span="6" class="tab-title">
						  计算死亡人数
					  </el-col>
				  </el-row>
				  <el-row>
					  <el-col :span="12" :offset="6" v-if="isCopy">
						  <span style="font-size: 16px;font-weight: bold;font-style: italic;">D = ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">i</sub>（RD<sub>i</sub> * S<sub>i</sub> * P<sub>t</sub>）</span><br/><br/>
						  D为评估区死亡人数，RD<sub>i</sub>为公里格网在i烈度下的死亡率，
						  S<sub>i</sub> 为人口变化特征修正值（系数）（区间范围（0,10]），
						  计算死亡人数时，考虑灾区人口时空变化特征作为修正，
						  主要考虑外出务工比例及外出和回家规律、景点旺季游客规模和淡季游客规模等关键因素。
						  P<sub>t</sub>为每个公里格网的总人数。<br/>
						  
					  </el-col>
					  <el-col :span="12" :offset="6" v-else>
						  <span style="font-size: 16px;font-weight: bold;font-style: italic;">D = ∑<sub style="position: absolute;top: 20px;margin-left: -6px;">i</sub>（RD<sub>i</sub> * 
						  <el-form-item prop="deathNumber" label-width="0" style="display: inline-block;">	
							  <el-input v-model="form.deathNumber" placeholder="" style="width: 100px;" />
						  </el-form-item>
							  * P<sub>t</sub>）</span><br/><br/>
						  D为评估区死亡人数，RD<sub>i</sub>为公里格网在i烈度下的死亡率，
						  S<sub>i</sub> 为人口变化特征修正值（系数）（区间范围（0,10]），
						  计算死亡人数时，考虑灾区人口时空变化特征作为修正，
						  主要考虑外出务工比例及外出和回家规律、景点旺季游客规模和淡季游客规模等关键因素。
						  P<sub>t</sub>为每个公里格网的总人数。<br/>
						  
					  </el-col>
				  </el-row>
		  <el-row>
					  <el-col :span="6" class="tab-title">
						  计算受伤人数
					  </el-col>
				  </el-row>
				  <el-row>
					  <el-col :span="12" :offset="6" v-if="isCopy">
						  <span style="font-size: 16px;font-weight: bold;font-style: italic;">F = D * C </span><br/><br/>
						  F为受伤人数，C为受伤人数与死亡人数的比例，一般为3到5倍。<br/>
						  
					  </el-col>
					  <el-col :span="12" :offset="6" v-else>
						  <span style="font-size: 16px;font-weight: bold;font-style: italic;">F = D * 
						  <el-form-item prop="injuries" label-width="0" style="display: inline-block;">
							  <el-input v-model="form.injuries" placeholder="[3,5]" style="width: 80px;" /> 
						  </el-form-item>	
						  </span><br/><br/>
						  F为受伤人数，C为受伤人数与死亡人数的比例，一般为3到5倍。<br/>
					  </el-col>
				  </el-row>
		</el-form>
		<template #footer>
		  <div class="dialog-footer">
			<el-button type="primary" @click="copyForm" v-if="isCopy">复 制</el-button>
			<el-button type="primary" @click="saveForm" v-if="!isCopy&&Default=='1'" :disabled="isDisabled">保 存</el-button>
			<el-button type="primary" @click="editForm" v-if="!isCopy&&Default=='0'" :disabled="isDisabled">保 存</el-button>
			<el-button type="primary" @click="delForm" v-if="!isCopy&&Default=='0'">删 除</el-button>
			<el-button plain @click="cancel">取 消</el-button>
		  </div>
		</template>
	  </el-dialog>
	</div>
  </template>
  
  <script setup>
  import { listCasualties, getModelCasualties, getModelCasualtiesForCopy, delCasualties, addCasualties, updateCasualties } from "@/api/modelmanage/casualties";
  import { getProvince, getProvince2 , getChildArea} from "@/api/system/division";
  import { getLanderRoles, getLanderProvince } from "@/api/basedatamanage/common.js"
  import { getUserId, setUserId } from '@/utils/auth'
  import { isDecimal } from '@/utils/validate'
  import useUserStore from '@/store/modules/user'
  
  const userStore = useUserStore();
  const { proxy } = getCurrentInstance();
  
  const casualtiesList = ref([]);
  const isEdit = ref(false);
  const isCopy = ref(true);
  const Default = ref("1");
  const radio = ref("1");
  const isCityEdit = ref(true);
  const isEditDefault = ref(true);
  const isShow = ref(true);
  const open = ref(false);
  const loading = ref(true);
  const showSearch = ref(true);
  const ids = ref([]);
  const single = ref(true);
  const multiple = ref(true);
  const total = ref(0);
  const title = ref("");
  const submitTime = ref("");//提交时间
  const provinceData = ref([]);//省
  const cityData = ref([]);//市
  const areaData = ref([]);//区、县
  
  const provinceFormData = ref([]);//表单省 
  const cityFormData = ref([]);//表单市
  const areaFormData = ref([]);//表单区、县
  
  const isDisabled = ref(false);
  
  // 保留三位小数
  const positive3decimals = (rule, value, callback) => {
	  value = String(value)
	  if (isNaN(value)|| !value) {
	  return callback(new Error());
	}
	var re = /^([0-9]+[\d]*(.[0-9]{3}))$/;
	if (!re.test(value)) {
	  callback(new Error());
	}else{
	  callback();
	}
  }
  
  // 保留两位小数
  const positive2decimals = (rule, value, callback) => {
	  value = String(value)
	  if (isNaN(value)|| !value) {
	  return callback(new Error());
	}
	var re = /^([0-9]+[\d]*(.[0-9]{2}))$/;
	if (!re.test(value)) {
	  callback(new Error());
	}else{
	  callback();
	}
  }
  
  // (0,10]数
  const positive0_10integer = (rule, value, callback) => {
	  value = String(value)
	  if (isNaN(value)|| !value) {
	  return callback(new Error());
	}
	var re = /^(([1-9](\.\d{1,2})?)|10|10.0)?$/;
	if (!re.test(value)) {
	  callback(new Error());
	}else{
	  callback();
	}
  }
  
  // [3,5]整数
  const positive3_5integer = (rule, value, callback) => {
	  value = String(value)
	  if (isNaN(value)|| !value) {
	  return callback(new Error());
	}
	var re = /^([3-5])$/;
	if (!re.test(value)) {
	  callback(new Error());
	}else{
	  callback();
	}
  }
  const data = reactive({
	form: {},
	queryParams: {
	  page: 1,
	  rows: 10,
	  province: null,
	  city: null,
  
	  
	},
	rules: {
	  taskCode: [
		{ required: true, message: "任务编号不能为空", trigger: "blur" }
	  ],
	  modelName: [
		{ required: true, message: "模型名称不能为空", trigger: "blur" }
	  ],
	  province: [
		{ required: true, message: "省不能为空", trigger: "blur" }
	  ],
	  provinceId: [
		{ required: true, message: "省不能为空", trigger: "change" }
	  ],
	  city: [
		{ required: true, message: "市不能为空", trigger: "change" }
	  ],
	  cityId: [
		{ required: false, message: "市不能为空", trigger: "change" }
	  ],
	  area: [
		{ required: true, message: "区/县不能为空", trigger: "blur" }
	  ],
	  areaId: [
		{ required: true, message: "区/县 不能为空", trigger: "blur" }
	  ],
	  smrsNumber1: [    
		{ required: true, message: "保留三位小数", trigger: "blur", validator: positive3decimals }  
	  ],
	  smrsNumber2: [    
		{ required: true, message: "保留两位小数", trigger: "blur", validator: positive2decimals }  
	  ],
	  deathNumber: [    
		{ required: true, message: "（0,10]之间的数,最大两位小数", trigger: "blur", validator: positive0_10integer }  
	  ],
	  injuries: [    
		{ required: true, message: "[3,5]之间的整数", trigger: "blur", validator: positive3_5integer }  
	  ],
  
	}
  });
  
  const { queryParams, form, rules } = toRefs(data);
  
  /** 查询人口伤亡计算模型列表 */
  function getList() {
	loading.value = true;
	listCasualties(queryParams.value).then(response => {
	  casualtiesList.value = response.data.rows;;
	  total.value = response.data.total;
	  loading.value = false;
	});
  }
  
  /** 获取省列表 */
  function getProvinceData() {
	  getProvince2().then(response => {
		  provinceData.value = response.data;
	  });
  }
  
  function getProvinceFormData() {
	  getProvince().then(response => {
		  provinceFormData.value = response.data;
	  });
  }
  
  function editProvinceFormData(provinceId,cityId) {
	  getProvince().then(response => {
		  provinceFormData.value = response.data;
	  });
	  getChildArea(provinceId).then(response => {
	  cityFormData.value = response.data;
	  });
	  getChildArea(cityId).then(response => {
		  areaFormData.value = response.data;
	  });
  }
  
  function chooseRadio(value){
	  console.log(value)
	  if(value == "2"){
		  isCityEdit.value = false
		  
	  }else{
		  isCityEdit.value = true
		  form.value.city = "全部"
		  form.value.cityId = ""
	  }
  }
  
  function chooseProvince(value){
	  queryParams.value.city = null;
	  queryParams.value.area = null;
	  cityData.value = [];
	  areaData.value = [];
	  getChildArea(value).then(response => {
	  cityData.value = response.data;
	  });
  //	provinceData.value.map(item => {//遍历数据
  //		if(item.id == value){
  //			if(item.name == "北京市"||item.name == "天津市"||item.name == "上海市"||item.name == "重庆市"){
  //		    cityData.value.push(JSON.parse(JSON.stringify(item)));
  //			}else{
  //				getChildArea(value).then(response => {
  //			    cityData.value = response.data;
  //				});
  //			}
  //			return;
  //		}   
  //})		
  }
  
  function chooseFormProvince(value){
	  form.value.city = null;
	  form.value.area = null;
	  cityFormData.value = [];
	  areaFormData.value = [];
	  getChildArea(value).then(response => {
	  cityFormData.value = response.data;
	  });	
  }
  
  function chooseCity(value){
	  queryParams.value.areaId = null;
	  areaData.value = [];
	  getChildArea(value).then(response => {
		  areaData.value = response.data;
	  });
  }
  
  function chooseFormCity(value){
	  form.value.area = null;
	  areaFormData.value = [];
	  getChildArea(value).then(response => {
		  areaFormData.value = response.data;
	  });
  }
  function chooseTaskName(value){
	  taskNameData.value.map(item => {//遍历数据
		  if(item.taskName == value){
			  form.value.taskCode = item.taskNum;
			  console.log(form.value.taskCode)
			  return;
		  }   
	  })	
  
  }
  // 取消按钮
  function cancel() {
	open.value = false;
	reset();
  }
  
  // 表单重置
  function reset() {
	form.value = {
	  id: null,
	  modelName: null,
	  province: null,
	  provinceId: null,
	  city: null,
	  cityId: null,
	  area: null,
	  areaId: null,
  
	  smrsNumber1: null,
	  smrsNumber2: null,
	  injuries: null,
	  isDefault: null,
	  deathNumber: null,
  
	};
	proxy.resetForm("casualtiesRef");
  }
  
  /** 搜索按钮操作 */
  function handleQuery() {
	queryParams.value.page = 1;
	
	getList();
  }
  
  /** 重置按钮操作 */
  function resetQuery() {
	  cityData.value = [];
	  areaData.value = [];
	proxy.resetForm("queryRef");
	handleQuery();
  }
  
  // 多选框选中数据
  function handleSelectionChange(selection) {
	ids.value = selection.map(item => item.id);
	single.value = selection.length != 1;
	multiple.value = !selection.length;
  }
  
  //获取当前日期函数
  function getNowFormatDate() {
	let date = new Date(),
	  seperator1 = '-', //格式分隔符
	  year = date.getFullYear(), //获取完整的年份(4位)
	  month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
	  strDate = date.getDate() // 获取当前日(1-31)
	if (month >= 1 && month <= 9) month = '0' + month // 如果月份是个位数，在前面补0
	if (strDate >= 0 && strDate <= 9) strDate = '0' + strDate // 如果日是个位数，在前面补0
   
	let currentdate = year + seperator1 + month + seperator1 + strDate 
	return currentdate
  }
  
  
  
  /** 查看按钮操作 */
  function edit(row) {
	reset();
	const id = row.id 
	if(row.isDefault=="1"){
		isCopy.value = true;
		Default.value = "1";
		title.value = "系统默认人员伤亡计算模型";
	}else{
		isCopy.value = false;
		Default.value = "0";
		title.value = "人员伤亡计算模型";
	}
	
	getModelCasualties(id).then(response => {
		
	  form.value = response.data;
	  
	  open.value = true;
	  if(form.value.city=="全部"){
		  radio.value = "1"
		  isCityEdit.value = true
	  }else{
		  radio.value = "2"
		  isCityEdit.value = false
	  }
	  if(form.value.isDefault=="0"){
		  isEditDefault.value = true
	  }else{
		  isEditDefault.value = false
	  }
	  
	});
  }
  
  /*复制*/
  const copyForm = async() => {
	  await getModelCasualtiesForCopy(form.value.id).then(response => {  	
	  form.value = response.data;
	  isCopy.value = false;
		  form.value.modelName = null;
		  form.value.isDefault = "0";    
	});
	  
	  title.value = "复制人员伤亡计算模型";
	  if(isDisableds.value){
	  form.value.provinceId = AdminProvinceId.value;
	  chooseFormProvince(form.value.provinceId);
	}
  }
  
  /*新增*/
  function saveForm() {
	  console.log("新增")
	  console.log(form.value.cityId)
	  
	  proxy.$refs["casualtiesRef"].validate(valid => {
	  if (valid) {
		  if(radio.value == "1"){
				  form.value.cityId = "全部"
			  }else{
				  if(form.value.cityId!=null){
					  form.value.cityId = JSON.parse(JSON.stringify(form.value.cityId)).join(",")
				  }
				   
			  }
			  isDisabled.value = true;
			  addCasualties({
				  "modelName":form.value.modelName,
			  "smrsNumber1":form.value.smrsNumber1,
			  "smrsNumber2":form.value.smrsNumber2,
			  "injuries":form.value.injuries,
			  "isDefault":form.value.isDefault,
			  "province":form.value.provinceId,
			  "city":form.value.cityId,
			  "deathNumber":form.value.deathNumber
			  }).then(response => {
				proxy.$modal.msgSuccess("新增成功");
				open.value = false;
				isDisabled.value = false;
				getList();
			  }).catch(err=>{isDisabled.value = false;});
		  }
	})
	  
  }
  /*编辑*/
  function editForm() {
	  console.log("编辑")
	  proxy.$refs["casualtiesRef"].validate(valid => {
	  if (valid) {
			  isDisabled.value = true;
			  updateCasualties(form.value).then(response => {
				  if(response.message=="修改失败，只能修改自己创建的模型"){
					  isDisabled.value = false;
					  proxy.$modal.msgWarning(response.message);
				  }else{
					  proxy.$modal.msgSuccess(response.message);
					  open.value = false;
					  isDisabled.value = false;
					getList();
				  }
				//proxy.$modal.msgSuccess("修改成功");
				
			  }).catch(err=>{isDisabled.value = false;});
		  }
	})
	  
  }
  /*删除*/
  function delForm() {
	  console.log("删除")	
	  const id = form.value.id;
	proxy.$modal.confirm('是否确认删除？').then(function() {
	  //return delCasualties(id);
	}).then(() => {
		delCasualties(id).then(response => {  		
			  if(response.message=="删除失败，只能删除自己创建的模型"){	    		
				  proxy.$modal.msgWarning(response.message);
			  }else{
				  proxy.$modal.msgSuccess(response.message);
				  open.value = false;
				getList();
			  }		  
		  });
  //  getList();
  //  open.value = false;
  //  proxy.$modal.msgSuccess("删除成功");
	}).catch(() => {
		
	});
	  
  }
  
  /** 删除按钮操作 */
  function handleDelete(row) {
	const ids = row.id || ids.value;
	proxy.$modal.confirm('是否确认删除？').then(function() {
	  return delDifference(ids);
	}).then(() => {
	  getList();
	  proxy.$modal.msgSuccess("删除成功");
	}).catch(() => {});
  }
  
  // 权限
  const isAdmin = async () => {
	  let res = await getLanderRoles()
	  const { code, data } = res
	  if (code == 200) {
		  const auth = data.split(',')
		  return auth
	  } else {
		  return Promise.reject(new Error(data))
	  }
  }
  const isDisableds = ref(false);
  const AdminProvinceId = ref('');
  const getDefaultProvice = async () => {
	  try {
		  let curAuth = await isAdmin()
	  let flag = curAuth.some(item=>item.includes('国家'))
	  isDisableds.value = !flag;
		  if (isDisableds.value) {
			  getLanderProvince().then(res => {
				  if (res.code == 200) {  
			AdminProvinceId.value = res.data
				  }else{
			AdminProvinceId.value = ''
		  }
			  })
			  getList();
		  } else {
			  getList()
		  }
	  } catch (error) {
  
	  }
  }
  getDefaultProvice()
  // getList();
  getProvinceData();
  getProvinceFormData();
  </script>
  <style scoped lang="scss">
	  .tab-title {
		  font-size: 16px;
		  font-weight: bold;
		  border-left: 4px solid var(--el-color-primary);
		  font-family: PingFangSC-Medium;
		  padding-left: 10px;
		  margin-bottom: 20px;
	  }
  </style>
  